package com.briup.jz.web.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.jz.bean.BasePrivilege;
import com.briup.jz.service.IPrivilegeService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/privilege")
@Api(description = "权限管理接口")
public class PrivilegeController {
    @Autowired
    private IPrivilegeService privilegeService;

    @ApiOperation(value = "查看权限")
    @GetMapping("findAll")
    public Message findAll() {
        List<BasePrivilege> list = privilegeService.findAll();
        return MessageUtil.success(list);
    }


    @ApiOperation(value = "添加或通过id修改权限")
    @PostMapping("savOrUpdate")
    public Message saveOrEdit(BasePrivilege privilege) {
    	privilegeService.saveOrEdit(privilege);
        return MessageUtil.success("保存成功");
    }

    @ApiOperation(value = "通过id删除权限")
    @ApiImplicitParam(name = "id", value = "类别唯一编号", required = true, paramType = "query")
    @GetMapping("deleteById")
    public Message delById(long id) {
    	privilegeService.delById(id);
        return MessageUtil.success("删除成功");
    }
}
